package com.bit.strongbaby;

import java.util.ArrayList;


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;

public class TalkTabThree extends Fragment {
	public static View view;
	ListView list1;

	ArrayList<Myitem> a1;
	String url = "http://wvvw.ticketmonster.co.kr/deallist/104193/104381";
	String url1 = "http://wvvw.ticketmonster.co.kr/deallist/104193/104413";
	String url2 = "http://wvvw.ticketmonster.co.kr/deallist/104193/104405";
	String url3 = "http://wvvw.ticketmonster.co.kr/deallist/104193/104397";
	ListView list;

	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		view = inflater.inflate(R.layout.talkthree, container, false);
		final Button btn1 = (Button) view.findViewById(R.id.btn111);
		list1 = (ListView) view.findViewById(R.id.sale_list);

		a1 = new ArrayList<Myitem>();
		Myitem mi;

		mi = new Myitem(R.drawable.te1, "");
		a1.add(mi);
		mi = new Myitem(R.drawable.te2, "");
		a1.add(mi);
		mi = new Myitem(R.drawable.te3, "");
		a1.add(mi);
		mi = new Myitem(R.drawable.te4, "");
		a1.add(mi);

		Myadapter myadapter = new Myadapter(getActivity(),
				R.layout.saleinfo_item, a1);

		ListView list = (ListView) view.findViewById(R.id.sale_list);
		list.setAdapter(myadapter);

		list.setOnItemClickListener(new ListViewItemClickListener());

		return view;
	}

	private class ListViewItemClickListener implements
			AdapterView.OnItemClickListener {
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			String item = (String) parent.getAdapter().getItem(position);
			String mes = "Select item = " + a1.get(position);
			if (id == 0) {
				Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
				Uri u = Uri.parse(url);
				i.setData(u);
				startActivity(i);
			} else if (id == 1) {
				Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url1));
				Uri u = Uri.parse(url1);
				i.setData(u);
				startActivity(i);
			}

		}
	}
}
